<template>
    <div>
   <el-row>
        <e-col style="float: left;padding-top: 20px;">
            <span>选择校区:</span>
            <el-select v-model="pushRecordStudent.school" filterable size="mini" clearable>
                <el-option 
                    v-for="item in campus" 
                    :key="item.id" 
                    :label="item.campusName" 
                    :value="item.campusName">
                </el-option>
            </el-select>
            <!-- <span>推送类型:</span>
            <el-select v-model="pushRecordStudent.pushStatus" filterable size="mini" clearable>
                <el-option 
                    v-for="item in options" 
                    :key="item.value" 
                    :label="item.label" 
                    :value="item.value">
                </el-option>
            </el-select> -->
            <span>通知类型:</span>
            <el-select v-model="pushRecordStudent.noticeType" filterable size="mini" clearable>
                <el-option 
                    v-for="item in noticeParent" 
                    :key="item.id" 
                    :label="item.noticeType" 
                    :value="item.noticeType">
                </el-option>
            </el-select>
        </e-col> 


        <e-col style="float: left; padding-top: 20px;">
            <!-- <span>推送时间:</span>
            <el-date-picker
                v-model="pushRecordStudent.pushTime"
                size = "mini"
                align="right"
                type="date"
                placeholder="选择日期"
                :picker-options="pickerOptions">
            </el-date-picker> -->
            <!-- <el-select class="forminfo" v-model="pushRecordStudent.pushTime" filterable size="mini" clearable>
                <el-option 
                    v-for="item in campus" 
                    :key="item.id" 
                    :label="item.campusName" 
                    :value="item.campusName">
                </el-option>
            </el-select> -->
            <span>签到状态:</span>
            <el-select class="forminfo" v-model="pushRecordStudent.signStatus" filterable size="mini" clearable>
                <el-option 
                    v-for="item in signType" 
                    :key="item.id" 
                    :label="item.signType" 
                    :value="item.signType">
                </el-option>
            </el-select>
            <span>姓名:</span>
            <el-select class="forminfo" v-model="pushRecordStudent.studentName" filterable size="mini" clearable>
                <el-option 
                    v-for="item in pushRecordStudent" 
                    :key="item.id" 
                    :label="item.studentName" 
                    :value="item.studentName">
                </el-option>
            </el-select>
            <span></span>
            <el-button plain icon="el-icon-search" size="mini" @click="studentPushInfo"></el-button>
            <el-button plain icon="el-icon-delete" size="mini" @click="reset"></el-button>
        </e-col> 

        <!-- <el-col style="padding-top: 20px;">
        <span  style="float:left; ">数量: 124243</span>
        </el-col> -->
    </el-row>

    <el-divider></el-divider>
    
    <el-table
      :data="studentPushData"
      style="width: 100%">
      <el-table-column
        prop="noticeType"
        label="通知类型"
        width="180">
      </el-table-column>
      <el-table-column
        prop="studentName"
        label="学员"
        width="180">
      </el-table-column>
      <el-table-column
        prop="course"
        label="课程">
      </el-table-column> 
      <el-table-column
        prop="signStatus"
        label="签到状态">
      </el-table-column> 
      <el-table-column
        prop="school"
        label="校区">
      </el-table-column> 
      <el-table-column
        prop="pushTime"
        label="推送时间">
      </el-table-column>
      <el-table-column
        prop="pushStatus"
        label="推送状态">
      </el-table-column>
    </el-table>

    <!-- 分页 -->
    <div class="block">
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="page"
      :page-sizes="[5, 10, 15, 20]"
      :page-size="size"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>

    </div>
</template>
<script>
export default {
    data() {
        return {
            pushRecordStudent:{},
            campus: [],
            studentPushData: [],
            noticeParent:[],
            eduStudent:[],
            page:1,
            size:5,
            total:0,
            pickerOptions: {
            disabledDate(time) {
              return time.getTime() > Date.now();
            },
            shortcuts: [{
              text: '今天',
              onClick(picker) {
                picker.$emit('pick', new Date());
                }
            }, {
              text: '昨天',
              onClick(picker) {
                const date = new Date();
                date.setTime(date.getTime() - 3600 * 1000 * 24);
                picker.$emit('pick', date);
            }
            }, {
              text: '一周前',
              onClick(picker) {
                const date = new Date();
                date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
                picker.$emit('pick', date);
              }
            }]
            },
            options:[
                {
                    value: 1,
                    label: '短信推送'
                },
                {
                    value: 2,
                    label: '邮件推送'
                }
            ],
            signType:[],

        }
    },
    mounted() {
        this.$axios.get("/schoolSet/findCamps").then(res =>{
            console.log(res.data);
            this.campus = res.data.data.records
        }),
        this.$axios.get("/push/findSignType").then(res =>{
            this.signType = res.data.data
        }),
        this.$axios.get("/push/findStudentNameList").then(res =>{
            this.pushRecordStudent = res.data.data
        }),
        this.$axios.get("/notice/findNoticeParentList").then(res =>{
            this.noticeParent = res.data.data
        }),
        this.studentPushInfo();
    },
    methods: {
        handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
        },
        handleCurrentChange(val) {
        this.page = val
        this.studentPushInfo()
        
        },
        studentPushInfo(){
            let data = {
                school: this.pushRecordStudent.school,
                pushStatus: this.pushRecordStudent.pushStatus,
                noticeType: this.pushRecordStudent.noticeType,
                pushTime: this.pushRecordStudent.pushTime,
                signStatus: this.pushRecordStudent.signStatus,
                studentName: this.pushRecordStudent.studentName,
                page: this.page,
                size: this.size
                
            }
            console.log(data);
            this.$axios.post("/push/findRecordStudent",data).then(res =>{
                if(res.data.code == 200){
                    console.log(res.data);
                    this.studentPushData = res.data.data.records;
                    this.total = res.data.data.total
                }      
            })
        },
        reset(){
            this.pushRecordStudent = {}
        }

    }
}
</script>
<style scoped>
span{
   padding-left:50px ;
}


</style>